package member.dao;

import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.ImprovedNamingStrategy;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.SessionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * <p>
 * This component and its source code representation are copyright protected
 * and proprietary to The Trivera Group, Inc., Worldwide D/B/A Trivera Technologies
 *
 * This component and source code may be used for instructional and
 * evaluation purposes only. No part of this component or its source code
 * may be sold, transferred, or publicly posted, nor may it be used in a
 * commercial or production environment, without the express written consent
 * of the Trivera Group, Inc.
 *
 * Copyright (c) 2015 The Trivera Group, LLC.
 * http://www.triveratech.com   http://www.triveragroup.com
 * </p>
 * @author The Trivera Group Tech Team.
 */


public class SessionUtil {
  private static final Log log = LogFactory.getLog(SessionUtil.class);



  public static  final  SessionFactory sessionFactory;

  static {
    try {
      Configuration cfg = new org.hibernate.cfg.Configuration();
      cfg.addResource("hibernate.cfg.xml");
      cfg.configure();
      ServiceRegistry svcReg = new StandardServiceRegistryBuilder()
		.applySettings(cfg.getProperties())
		.build();

      sessionFactory = cfg.buildSessionFactory(svcReg);

    } catch (Throwable ex) {
      log.error("Initial SessionFactory creation failed." + ex);
      throw new ExceptionInInitializerError(ex);
    }
  }
}






